package com.education.common.utils;


import lombok.Data;
@Data
public class Rest<T> {

	// @ApiModelProperty(value = "是否成功")
	// private boolean success = true;

	private String code = "code";

	private String msg = "msg";

	private T data;

	public void getSuccessJsonObject(T bean) {
		getSuccessJsonObject();
		data = bean;

	}

	public void getSuccessJsonObject(String msg1, String data1) {
		code = ResultCodeEnum.SUCCESS.getValue().toString();
		if (msg1 == null || msg1.equals("")) {
			msg = ResultCodeEnum.SUCCESS.getKey();
		} else {
			msg = msg1;
		}
		data = (T) data1;
	}

	public void getSuccessJsonObject() {

		code = ResultCodeEnum.SUCCESS.getValue().toString();
		msg = ResultCodeEnum.SUCCESS.getKey();

	}

	public void getSuccessJsonObject(String msg1) {

		code = ResultCodeEnum.SUCCESS.getValue().toString();
		msg = msg1;

	}

	public void getFailJsonObject() {

		code = ResultCodeEnum.FAIL.getValue().toString();
		msg = ResultCodeEnum.FAIL.getKey();

	}

	public void getFailJsonObject(String msg1) {

		code = ResultCodeEnum.FAIL.getValue().toString();
		msg = msg1;

	}

	public void getResultJson(ResultCodeEnum resultCodeEnum) {

		code = resultCodeEnum.getValue().toString();
		msg = resultCodeEnum.getKey();

	}

	public void failed(Integer codeI, String msg1) {

		code = codeI.toString();
		msg = msg1;

	}

}
